//
//  ViewController.m
//  10701
//
//  Created by student on 16/2/22.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"
#import "BlueViewController.h"
#import "YellowViewController.h"
@interface ViewController ()
@property (nonatomic,strong) BlueViewController *blueVC;
@property (nonatomic,strong) YellowViewController *yellowVC;

@property (nonatomic,assign) BOOL curBlue;

@end

@implementation ViewController

- (BlueViewController *)blueVC
{
    if (!_blueVC) {
        _blueVC = [[BlueViewController alloc] init];
        
    }
    return _blueVC;
}
- (YellowViewController *)yellowVC
{
    if (!_yellowVC) {
        _yellowVC = [[YellowViewController alloc] init];
        
    }
    return _yellowVC;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)switch:(id)sender
{
    [UIView beginAnimations:@"ViewFilp" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1.25];
    
    if(self.curBlue)
    {
        [self.view insertSubview:self.yellowVC.view atIndex:0];
        [self.blueVC.view removeFromSuperview];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    }
    else
    {
        [self.view insertSubview:self.blueVC.view atIndex:0];
        [self.yellowVC.view removeFromSuperview];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
    }
    
    [UIView commitAnimations];// 动画开始播放
    
    self.curBlue = !self.curBlue;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
